import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';

export const columns: BasicColumn[] = [
  {
    title: '规则类型',
    dataIndex: 'aclType',
  },
  {
    title: '规则',
    dataIndex: 'subject',
  },
  {
    title: 'Topic',
    dataIndex: 'topic',
  },
  {
    title: '动作类型',
    dataIndex: 'action',
  },
  {
    title: '策略',
    dataIndex: 'aclStrategy',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'aclType',
    label: '规则类型',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      options: [
        { label: 'ALL', value: 'ALL' },
        { label: 'IP', value: 'IP' },
        { label: 'CLIENT_ID', value: 'CLIENT_ID' },
        { label: 'USER', value: 'USER' },
      ],
    },
  },
  {
    field: 'subject',
    label: '规则',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'topic',
    label: 'Topic',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'action',
    label: '动作类型',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      options: [
        { label: 'SUBSCRIBE', value: 'SUBSCRIBE' },
        { label: 'PUBLISH', value: 'PUBLISH' },
      ],
    },
  },
  {
    field: 'aclStrategy',
    label: '策略',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      options: [
        { label: 'ALLOW', value: 'ALLOW' },
        { label: 'OENY', value: 'OENY' },
      ],
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: 'id',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    field: 'aclType',
    label: '规则类型',
    component: 'Select',
    componentProps: {
      options: [
        { label: 'ALL', value: 'ALL' },
        { label: 'IP', value: 'IP' },
        { label: 'CLIENT_ID', value: 'CLIENT_ID' },
        { label: 'USER', value: 'USER' },
      ],
    },
    defaultValue: 'ALL',
  },
  {
    field: 'subject',
    label: '规则',
    component: 'Input',
    componentProps: { disabled: true },
    helpMessage: ['1. 限制IP: ip{限制的客户端IP}', '2. 限制客户端: 客户端ID', '3. 限制所有: all'],
    defaultValue: '*',
    required: true,
  },
  {
    field: 'topic',
    label: 'Topic',
    component: 'Input',
    required: true,
  },
  {
    field: 'action',
    label: '动作类型',
    component: 'Select',
    componentProps: {
      options: [
        { label: 'SUBSCRIBE', value: 'SUBSCRIBE' },
        { label: 'PUBLISH', value: 'PUBLISH' },
      ],
    },
    defaultValue: 'SUBSCRIBE',
  },
  {
    field: 'aclStrategy',
    label: '策略',
    component: 'Select',
    componentProps: {
      options: [
        { label: 'ALLOW', value: 'ALLOW' },
        { label: 'OENY', value: 'OENY' },
      ],
    },
    defaultValue: 'ALLOW',
  },
];
